package com.chat.service;

import com.chat.Local;
import com.chat.common.Message;
import com.chat.common.MessageType;
import com.chat.common.User;
import com.chat.view.*;
import javafx.application.Platform;

import static com.chat.view.AddFriendController.addfriend;
/*
该方法用于搜索id
 */
public class SearchFriend {
    public static boolean state=false;//记录查找好友的状态
    public SearchFriend(){

    }
    public SearchFriend(String addid) {
//        Platform.runLater(()-> {
//            ((javafx.scene.control.ListView) AddFriendView.$("addlist")).getItems().clear();
//        });
          state=false;
          Message msg=new Message();
          User user=new User();
          msg.setMesType(MessageType.MESSAGE_SEARCH_FRIEND);
          user.setUsername(Local.user.getUsername());
          user.setAddid(addid);
          msg.setData(user);
          ClientConnectServerThread clientConnectServerThread=ManageClientConnectServerThread.getClientConnectServerThread(Local.user.getUsername());
          clientConnectServerThread.send(msg);
    }
   public void setFriend(User user){
         addfriend.clear();
         addfriend.add(new AddListData(user.getNickname(),user.getQianming()));
         state=true;
   }
   public boolean getstate(){
         return state;
   }
}
